//
//  SEGUhomeMediator+IntelligentHardware.m
//  SEGBasicBussiness
//
//  Created by 刘山 on 2018/4/26.
//  Copyright © 2018年 刘山. All rights reserved.
//

#import "SEGUhomeMediator+IntelligentHardware.h"
NSString * const kTargetOpenDoor = @"OpenDoor";
NSString * const kActionNaviActionToOpenDoor= @"showDoorWithParams";
NSString * const kActionOpenDoorInitElevatorControlViewController= @"initElevatorControlViewController";
NSString * const kActionOpenDoorGetRecentDoorList = @"getRecentDoorListWithCallBack";
NSString * const kActionOpenDoorClickDoor = @"openDoorWithParams";
NSString * const kActionSubmitOpenDoorRecordHistory = @"submitOpenDoorRecordHistory";

@implementation SEGUhomeMediator (IntelligentHardware)

/**
 一键开门

 @param type 类型
 @param showedCallBack 成功回调
 @return vc
 */
- (UIViewController *)seg_showDoorWithType:(NSInteger)type showedCallBack:(void (^)(NSDictionary *))showedCallBack {
    return [self seg_showDoorWithType:type showedCallBack:showedCallBack disappearCallBack:nil];
}

/**
 一键开门

 @param type 类型
 @param showedCallBack 成功回调
 @param disappearCallBack 页面消失回调
 @return vc
 */
- (UIViewController*)seg_showDoorWithType:(NSInteger)type showedCallBack:(void(^)(NSDictionary *info))showedCallBack disappearCallBack:(void(^)(void))disappearCallBack {
    NSMutableDictionary *paramsToSend = [[NSMutableDictionary alloc] init];
    if (type) {
        paramsToSend[@"showType"] = [NSNumber numberWithInteger:type];
    }
    if (showedCallBack) {
        paramsToSend[@"showedCallBack"] = showedCallBack;
    }
    if (disappearCallBack) {
        paramsToSend[@"disappearCallBack"] = disappearCallBack;
    }
    return [self performTarget:kTargetOpenDoor action:kActionNaviActionToOpenDoor params:paramsToSend shouldCacheTarget:NO];
}

/**
 * 初始化梯控界面
 * @author Sam
 */
- (UIViewController*)seg_initElevatorControlViewController:(NSDictionary *)params{
    return [self performTarget:kTargetOpenDoor action:kActionOpenDoorInitElevatorControlViewController params:params shouldCacheTarget:NO];
}

/**
 获取前八个门禁 先返回本地数据 网络请求更新后，再返回新排序后的数据
 */
- (void)seg_getRecentDoorListWithCallBack:(void(^)(NSArray *doorList))callBack {
    NSMutableDictionary *paramsToSend = [[NSMutableDictionary alloc] init];
    if (callBack) {
        paramsToSend[@"callBack"] = callBack;
    }
    [self performTarget:kTargetOpenDoor action:kActionOpenDoorGetRecentDoorList params:paramsToSend shouldCacheTarget:NO];
}


/**
 点击某个门禁 触发开门事件
 
 @param params 点击门禁的字典数据
 */
- (void)seg_openDoorWithParams:(NSDictionary *)params completeCallback:(void(^)(NSDictionary *))callback {
    NSMutableDictionary *paramsToSend = [[NSMutableDictionary alloc] init];
    if (params) {
        paramsToSend[@"doorDic"] = params;
    }
    if (callback) {
        paramsToSend[@"callback"] = callback;
    }
    [self performTarget:kTargetOpenDoor action:kActionOpenDoorClickDoor params:paramsToSend shouldCacheTarget:NO];
}


/**
 上传历史的开门纪录
 */
- (void)seg_submitOpenDoorRecordHistory {
    [self performTarget:kTargetOpenDoor action:kActionSubmitOpenDoorRecordHistory params:nil shouldCacheTarget:NO];
}

@end
